package com.hyh.order.controller;


import com.hyh.feign.result.PageResult;
import com.hyh.order.domain.Orders;
import com.hyh.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/order")

public class OrderController {

    @Autowired
    private OrderService orderService;
    
    /*
     * @description: 生成我的订单
     * @param:  
     * @return:  
     * @author 
     * @date: 2024/3/21 16:45
     */
    @PostMapping("/createOrder/{id}")
    public PageResult createOrder(@PathVariable("id") Long id){
         return orderService.createOrder(id);
    }


    /*
     * @description: 修改订单状态
     * @param:
     * @return:
     * @author
     * @date: 2024/3/21 19:41
     */
    @PutMapping ("/updateOrder/{id}")
    public PageResult updateOrder(@PathVariable("id") Long id){
        return orderService.updateOrder(id);
    }


    /*
     * @description: 根据状态查询订单
     * @param:
     * @return:
     * @author
     * @date: 2024/3/21 19:46
     */
    @PostMapping("/getOrder")
    public PageResult getOrder(@RequestParam("userId") String userId,
                               @RequestParam("status") String status){
        return orderService.getOrder(userId,status);
    }



    /*
     * @description: 根据订单号查询订单
     * @param:
     * @return:
     * @date: 2024/3/22 20:52
     */
    @GetMapping("/getOrderById/{id}")
    public Orders getOrderById(@PathVariable("id") Long id){
        return orderService.getOrderById(id);
    }


    /*
     * @description: 查询是否存在订单
     * @param:
     * @return:
     * @author
     * @date: 2024/3/22 21:42
     */
    @GetMapping("/existOrder/{id}")
    public boolean existOrder(@PathVariable("id") Long id){
        return orderService.existOrder(id);
    }
}
